<?php
include_once '../comm/config.php';
include_once '../comm/checkpostandget.php';
$tag="center";
$pagetag="login";
include_once '../comm/wjt.php';
include_once '../comm/seo.php';
error_reporting(0);
session_start();
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>注册</title>
<link href="../template/<?=MOBAN?>/css/style.css" rel="stylesheet" type="text/css" />
<link  href="../template/<?=MOBAN?>/css/layout.css" rel="stylesheet" type="text/css" />
<link  href="../template/<?=MOBAN?>/css/login.css" rel="stylesheet" type="text/css" />
<link  href="../template/<?=MOBAN?>/css/comm.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/jquery.js"></script>
<script language="javascript" type="text/javascript">
$.ajaxSetup ({
    cache: false //关闭AJAX相应的缓存
});
regErr=new Array();
regErr[1]='恭喜，该用户名可以使用';
regErr[-1]='用户名不合法';
regErr[-2]='包含不允许注册的词语';
regErr[-3]='用户名已存在';

emailErr=new Array();
emailErr[1]='恭喜，该用户名可以使用';
emailErr[-1]='用户名不合法';
emailErr[-2]='包含不允许注册的词语';
emailErr[-3]='该邮箱以已注册';
//emailErr[-6]='email已存在';
var ddName;
var ddPass;
var ddPass2;
var ddQq;
var ddEmail;
var ddYzm;
function checkUsername(name){
		if(getLength(name)<3 || getLength(name)>15)
		{
			document.getElementById("ckuser").innerHTML = '<img src=../images/cuo.gif alt="错误" align=absmiddle /> <font color=#ff0000>用户名长度必须为 3 - 20 位</font>';
			ddName=0;
		}
		else
		{
			var re = RegExp("^[a-zA-Z0-9_\u4e00-\u9fa5]+$");
			if (!re.test(name)){
				document.getElementById("ckuser").innerHTML = '<img src=../images/cuo.gif alt="错误" align=absmiddle /> <font color=#ff0000>仅可使用汉字或数字字母和下划线</font>';
				ddName=0;
			}else{
			$.get('ckuser.php', 'name='+encodeURIComponent(name)+'&fresh=' + Math.random(), function(data){
				data=parseInt(data); 
				if(data<1) {
				document.getElementById("ckuser").innerHTML = '<img src=../images/cuo.gif alt="错误" align=absmiddle /> <font color=#ff0000>'+regErr[data]+'</font>';
				ddName=0;
			  }else{
				  document.getElementById("ckuser").innerHTML = '<img src=../images/dui.gif alt="正确" align=absmiddle /> <font color=#009900>'+regErr[data]+'</font>';
				  ddName=1;
				  }
			});
			}
		}
}

function getLength(str) {
    var len = str.length;
    var reLen = 0;
    for (var i = 0; i < len; i++) {        
        if (str.charCodeAt(i) < 27 || str.charCodeAt(i) > 126) {
            // 全角    
            reLen += 2;
        } else {
            reLen++;
        }
    }
    return reLen;    
} 

function checkqq2(qq2)
{
    	if(getLength(qq2) <= 4)
		{
			document.getElementById("ckqq2").innerHTML = '<img src=../images/cuo.gif alt="错误" align=absmiddle /> <font color=#ff0000>QQ号码应大于5位</font>';
			ddQq=0;
		}else
			{
				document.getElementById("ckqq2").innerHTML = '<img src=../images/dui.gif alt="正确" align=absmiddle /> <font color=#009900>QQ号码正确</font>';
				ddQq=1;	
			}
}

function checkpass(password)
{
    	if(getLength(password)<6 || getLength(password)>20)
		{
			document.getElementById("ckpass").innerHTML = '<img src=../images/cuo.gif alt="错误" align=absmiddle /> <font color=#ff0000>密码长度必须为 6 - 20 位</font>';
			ddPass=0;
		}
		else
		{
			document.getElementById("ckpass").innerHTML = '<img src=../images/dui.gif alt="正确" align=absmiddle /> <font color=#009900>密码填写正确</font>';
			ddPass=1;
			
		}
}    

function checkpass2()
{
    	if(getLength(document.getElementById("password_check").value)<6 || getLength(document.getElementById("password_check").value)>20)
		{
			document.getElementById("ckpass2").innerHTML = '<img src=../images/cuo.gif alt="错误" align=absmiddle /> <font color=#ff0000>密码长度必须为 6 - 20 位</font>';
			ddPass2=0;
		}
		else if (document.getElementById("password").value!=document.getElementById("password_check").value)
		{
			document.getElementById("ckpass2").innerHTML = '<img src=../images/cuo.gif alt="错误" align=absmiddle /> <font color=#ff0000>两次密码输入不一致！</font>';
			ddPass2=0;
		}
		else
		{
			document.getElementById("ckpass2").innerHTML = '<img src=../images/dui.gif alt="正确" align=absmiddle /> <font color=#009900>密码输入正确</font>';
			ddPass2=1;
		}
		document.getElementById("hint3").style.display="none";
}    
function checkemail()
{
		var str = document.getElementById("username").value;    
        if(str.length!=0)
		{    
			reg=/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;    
			if(!reg.test(str))
			{    
				document.getElementById("username").innerHTML = '<img src=../images/cuo.gif alt="错误" align=absmiddle /> <font color=#ff0000>邮件格式填写错误</font>';
				ddEmail=0;
			}
			else
			{
				$.get('ckuser.php', 'name='+encodeURIComponent(str)+'&fresh=' + Math.random(), function(data){
				    data=parseInt(data); 
					if(data<1) {
			            document.getElementById("ckemail").innerHTML = '<img src=../images/cuo.gif alt="错误" align=absmiddle /> <font color=#ff0000>'+emailErr[data]+'</font>';
						ddEmail=0;
		            }else{
			            document.getElementById("ckemail").innerHTML = '<img src=../images/dui.gif alt="正确" align=absmiddle /> <font color=#009900>'+emailErr[data]+'</font>';
						ddEmail=1;
			        }
				});
			}
		}
		else
		{
				document.getElementById("ckemail").innerHTML = '<img src=../images/cuo.gif alt="错误" align=absmiddle /> <font color=#ff0000>请填写电子邮件</font>';
				ddEmail=0;
		}
		document.getElementById("hint1").style.display="none";
} 
function checkyzm()
{
	var yzm = document.getElementById("yzm").value;
    	if(getLength(yzm)!=4)
		{
			document.getElementById("ckyzm").innerHTML = '<img src=../images/cuo.gif alt="错误" align=absmiddle /> <font color=#ff0000>验证码填写错误</font>';
			ddYzm=0;
		}
		else
		{
			document.getElementById("ckyzm").innerHTML = '请填写验证码';
			ddYzm=1;
			
		}
}  
function checkall()
{
	checkemail();
	checkpass2();
	if(ddEmail==0||ddPass2==0||(document.getElementById("ckRead").checked)=="checked")
	{
		alert('请填写完注册内容！');
		return false;
	}
}

//判断
function hint(id)
{
	document.getElementById(id).style.display="block";
}
function hinthide(id)
{
	document.getElementById(id).style.display="none";
}

function tip(id)
{
	if(id==1)
	{
		document.getElementById("tipnav").style.display="block";
	}
	if(id==2)
	{
		document.getElementById("tipnav").style.display="none";
	}
}

function tip1()
{
$("#tipnav").bind("mouseleave",
function()
{
		document.getElementById("tipnav").style.display="none";
}
);
}

function doEnter()
{
	document.getElementById("pw1").style.display="none";
	document.getElementById("password_check").style.display="block";
	document.getElementById("password_check").focus();
}
</script>
</head>
<body>
<div class='head_warpC'>
	<div class='slideup layout_head'>
        <ul class="headerTopLeft">
            <li class="home"><a href="../index.php" onmousemove="tip(1);"  >优米库首页</a></li>
            <li><a href="../comm/shortcut.php">放到桌面</a></li>
            <li><a href="#dd" onClick="AddFavorite('<?=$navheadurl?>','<?=WEBNICK?>')">添加到收藏夹</a></li>
            <li><a href="msg_list.php?act=send">咨询优助手</a></li>
            <li><a href="msg_list.php?act=send">提意见给客服</a></li>
        </ul>
        <ul class="headerTopRight FRight">
          <li class="HUserimg"><img src="../upload/avatar/<?=get_avatar_filepath($_SESSION['dduserid'], $size = 'big')?>" width="40" height="40"></li>
          <li><a href="center.php">我的优米库</a></li>
          <li><a href="register.php">成为米粒</a></li>
		  <?php
          if($_SESSION["duoduouser"]==NULL)
          {
              echo "<li><a href=login.php>登录</a></li>";
              echo "<li><a href=center.php>您好，游客".$_SESSION["tmpuser"]."</a></li>";
          }
          else
          {
              echo "<li><a href=exit.php>退出</a></li>";
              echo "<li><a href=center.php>您好，".$_SESSION["duoduouser"]."</a></li>";	
          }
          ?>
        </ul>
        <div class="clears"></div>
    </div>  
    <div class="dhmenu" id="tipnav" onmouseout="tip1();" style="display:none">
        <div class="fm">
        <a class="active">攒米</a><a href='../malllist.php'>返米店铺</a><!--<a href='#'>返米宝</a>--><a href='tuiguang_url.php'>免费攒米</a><!--<a href='#'>省钱检测</a>--><a class="active">兑换</a><a href="../huan.php">用米兑换</a><a href="tixian.php">申请提现</a>
        <a href='#' class="active">社区</a><a href='../baobeilist.php'>米粒晒吧</a>
        <br /><a class="active">店铺</a><a href='#'>优米联盟</a>
       </div>
   </div>

<div class="layout_head reg"> 
  <a href="../index.php" class="logo_reg"><img src="../template/<?=MOBAN?>/images/logo_zhuce.png" width="226" height="57" /></a>
  <ul class="reg_enter" style="margin-top:40px">
      <li><a href="getpassword.php">找回密码</a></li>
      <li><a href="login.php">登录</a></li>
      <li><img src="../template/<?=MOBAN?>/images/creatUser.png" width="102" height="24" /></li>
  </ul>
</div>
</div>  


<form id="form" name="form" method="post" action="savereg.php" onsubmit="return checkall();">
<div class='layout_body MarginT10'>
<div class="FLeft" style="_width:650px;">
<h3 class="LineHeight32 col14red MarginT10">您好，游客<?=$_SESSION["tmpuser"]?></h3>
<ul class="reg_ul">
<li class="MarginT10 MarginB10"><input type="text" name="username" id="username" onblur="checkemail();" onfocus="hint('hint1');this.value='';"   size="20" maxlength="20" value="这里输入您的邮箱" class="regtxt"><div class="clears"></div><div id="ckemail">邮箱：必填</div></li>
<li class="notive" id="hint1" style="display:none">
这是您的登录账号也是找回密码的必要条件
可以是QQ、126邮箱，如：123456@qq.com
您不会接到任何垃圾邮件
</li>
<div class="clears"></div>
</ul>
<!--
<ul class="reg_ul">
<li class="MarginT10 MarginB10"><input name="nickname" type="text" onfocus="hint('hint2');" onblur="hinthide('hint2');this.value='';"  value="这里输入您的姓名" class="regtxt"><div class="clears"></div>姓名：可以不填</li>
<li class="notive" id="hint2" style="display:none">
2~7个以内的纯汉字姓名，或者3~14个字符以
内的纯英文
</li>
<div class="clears"></div>
</ul>
-->
<ul class="reg_ul">
<li class="MarginT10 MarginB10">
  <input name="pw1" type="text" id="pw1" value="这里输入密码" onfocus="doEnter();" class="regtxt">
  <input name="password" type="password" id="password_check" value="" onblur="checkpass2();" style="display:none" class="regtxt">
  <div class="clears"></div><div id="ckpass2">密码：必填</div>
</li>
<li class="notive" id="hint3" style="display:none">6~16个字符，不分大小写，可以是数字、字母</li>
<div class="clears"></div>
</ul>
<ul class="reg_ul1">
<input name="ckRead" id="ckRead" type="checkbox" value="" class="FLeft" style="width:14px;height:14px;margin-top:10px" checked="checked"/><em class="FLeft MarginL5">我已经阅读并接受"<span class="ColorRed"><a class="ColorRed" href="../read.php?id=29">本站声明</a></span>""<span class="ColorRed"><a class="ColorRed" href="../read.php?id=30">服务条款</a></span>"和"<span class="ColorRed"><a class="ColorRed" href="../read.php?id=31">隐私保护和个人信息利用政策</a></span>"</em>
</ul>
<div class="clears"></div>
<ul class="reg_ul">
<li class="MarginTB30"><input type="image" src="../template/<?=MOBAN?>/images/creatUserbtn.gif" width="195" height="56" /></li>
</ul>
</div>
<div class="FRight" style="_width:260px;overflow:hidden;">
<ul class="REG_detail" style="_margin-left:0px;">
<li><img src="../template/<?=MOBAN?>/images/search.gif" width="39" height="40" class="FLeft"/><p class="FLeft MarginL10">通过返米店铺，你将得到很多米，
成功创建账号后，你就是米粒了！</p>
<div class="clears"></div>
</li>
<li><img src="../template/<?=MOBAN?>/images/user.gif" width="39" height="40" align="middle" class="FLeft"/><p class="FLeft MarginL10">你可以使用米在优米库兑换商品
也可以提取现金！</p>
<div class="clears"></div></li>
<li>你只需要知道，优米库会让你得到更多优惠
Umiku是最实在的优惠网站</li>
<li><img src="../template/<?=MOBAN?>/images/d.gif" width="157" height="22" /></li>
</ul>
</div>
</div>
</form>

<?php
include("../template/".MOBAN."/footer.tpl.php");
?>
</body>
</html>
